package com.ruoyi.transport.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.transport.domain.PurchaseTransport;
import com.ruoyi.transport.service.IPurchaseTransportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购运输管理Controller
 * 
 * @author yx
 */
@RestController
@RequestMapping("/transport/transport")
public class PurchaseTransportController extends BaseController
{
    @Autowired
    private IPurchaseTransportService purchaseTransportService;

    /**
     * 查询采购运输管理列表
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:list')")
    @GetMapping("/list")
    public TableDataInfo list(PurchaseTransport purchaseTransport)
    {
        startPage();
        List<PurchaseTransport> list = purchaseTransportService.selectPurchaseTransportList(purchaseTransport);
        return getDataTable(list);
    }

    /**
     * 导出采购运输管理列表
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:export')")
    @Log(title = "采购运输管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchaseTransport purchaseTransport)
    {
        List<PurchaseTransport> list = purchaseTransportService.selectPurchaseTransportList(purchaseTransport);
        ExcelUtil<PurchaseTransport> util = new ExcelUtil<PurchaseTransport>(PurchaseTransport.class);
        util.exportExcel(response, list, "采购运输管理数据");
    }

    /**
     * 获取采购运输管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:query')")
    @GetMapping(value = "/{transportId}")
    public AjaxResult getInfo(@PathVariable("transportId") Integer transportId)
    {
        return success(purchaseTransportService.selectPurchaseTransportByTransportId(transportId));
    }

    /**
     * 新增采购运输管理
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:add')")
    @Log(title = "采购运输管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurchaseTransport purchaseTransport)
    {
        return toAjax(purchaseTransportService.insertPurchaseTransport(purchaseTransport));
    }

    /**
     * 修改采购运输管理
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:edit')")
    @Log(title = "采购运输管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurchaseTransport purchaseTransport)
    {
        return toAjax(purchaseTransportService.updatePurchaseTransport(purchaseTransport));
    }

    /**
     * 删除采购运输管理
     */
    @PreAuthorize("@ss.hasPermi('transport:transport:remove')")
    @Log(title = "采购运输管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transportIds}")
    public AjaxResult remove(@PathVariable Integer[] transportIds)
    {
        return toAjax(purchaseTransportService.deletePurchaseTransportByTransportIds(transportIds));
    }
}
